//
//  ScoreViewController.m
//  LiveSoftware
//
//  Created by lanou3g on 15/7/10.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#pragma mark - Score 主界面

#define kTitleY kScreenIp6(20)
#define kBtnWidth kScreenIp6(60)
#define kBtnHeight kScreenIp6(40)

#import "ScoreViewController.h"
#import "CommonView.h"
#import "ScoreTableViewCell.h"

#import "ScoreModel.h"

/**
 *  比赛状态
 0  表示未开赛
 1  表示上半场
 2  表示中场
 3  表示下半场
 -1  表示已结束
 */




//二级页面
#import "EventAndAnalysisViewController.h"


//事件
#import "ScoreEventViewController.h"

//分析
#import "ScoreAnalysisViewController.h"


//引入篮球头文件
#import "FootballViewController.h"

//筛选页面
#import "FilterTeamViewController.h"

//闹钟
#import "AlarmClockManager.h"


#import "MyFootballPointTool.h"

@interface ScoreViewController () <UITableViewDataSource,UITableViewDelegate,UIScrollViewDelegate>


@property(nonatomic) BOOL isGreen ;

@property(nonatomic,strong) CommonTitleView *BaseView;


@property(nonatomic,strong)NSMutableArray *scoreModelArray;


@property(nonatomic,strong)NSMutableArray *pointModelArray;

@property(nonatomic,copy)NSString *totalTime;


/**
 *分数定时器
 */
@property(nonatomic,strong)NSTimer *scoreTimer;


/**
 *秒闪定时器
 */
@property(nonatomic,strong)NSTimer *miaoTimer;




//筛选出来的球队
@property(nonatomic,strong)NSArray *filterTeamTitleArray;
@property(nonatomic,strong)NSMutableArray *filterTeamIDArray;

@property(nonatomic,strong)NSArray *ResultFilterTeamTitleArray;
@property(nonatomic,strong)NSMutableArray *ResultFilterTeamIDArray;


@property(nonatomic,copy)NSString * LiveChangeData;


//解析出来的数据---即时
@property(nonatomic,copy)NSString *scoreData;

//解析出来的数据--赛果
@property(nonatomic,copy)NSString *resultScoreData;

//存放联赛名字的数组--即时
@property(nonatomic,strong)NSMutableArray   *leagueNameArray;
@property(nonatomic,strong)NSMutableArray *leagueIDArray;

//赛果
@property(nonatomic,strong)NSMutableArray   *leagueNameResultArray;
@property(nonatomic,strong)NSMutableArray *leagueIDResultArray;

//字典

@property(nonatomic,strong)NSDictionary *LeagueMessageDict;
@property(nonatomic,strong)NSDictionary *resultLeagueMessageDict;


/**
 *直播改变数据的
 */
@property(nonatomic,strong)NSArray *liveChangeKeysNameArray;
/**
 *将要比赛的Key
 */
@property(nonatomic,strong)NSArray *fauterKeysNameArray;
/**
 *正在比赛的key
 */
@property(nonatomic,strong)NSArray *goingKeysNameArray;
/**
 *赛果
 */
@property(nonatomic,strong)NSArray *scoreResultKeysNameArray;


/**
 *赛果ModelArray
 */
@property(nonatomic,strong)NSMutableArray *scoreResultModelArray;

//即时的行数
@property(nonatomic)NSInteger arrayCount;
@property(nonatomic)NSInteger missCount;



@property(nonatomic)NSInteger scoreResultCount;



// 判定篮球是否被选中
@property(nonatomic,getter=isSelected) BOOL selected;



@property(nonatomic,strong)UIButton *filterButton;

@end

@implementation ScoreViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    
#pragma mark 初始化数组
    
    //正在进行
    self.goingKeysNameArray =@[@"matchId",@"leagueId",@"matchState",@"startTime",@"curentTime",@"homeName",@"awayName",@"homeWholeGoals",@"awayWholeGoals",@"homeHalfGoals",@"awayHalfGoals",  @"homeRedCard",@"awayRedCard",@"homeYellowCard",@"awayYellowCard",@"yapan",@"other",@"homeRank",@"awayRank",@"isLived"];
    
    //将来的
    self.fauterKeysNameArray = @[@"matchId",@"leagueId",@"matchState",@"startTime",@"curentTime",@"homeName",@"awayName",@"homeWholeGoals",@"awayWholeGoals",@"homeRedCard",@"awayRedCard",@"homeYellowCard",@"awayYellowCard",@"yapan",@"other",@"homeRank",@"awayRank",@"isLived"];
    
    
    self.scoreResultKeysNameArray  =@[@"matchId",@"leagueId",@"matchState",@"startTime",@"curentTime",@"homeName",@"awayName",@"homeWholeGoals",@"awayWholeGoals", @"homeHalfGoals",@"awayHalfGoals",       @"homeRedCard",@"awayRedCard",@"homeYellowCard",@"awayYellowCard"];
    
    
    self.liveChangeKeysNameArray = @[@"matchId",@"matchState",@"startTime",@"curentTime",@"homeWholeGoals",@"awayWholeGoals", @"homeHalfGoals",@"awayHalfGoals",       @"homeRedCard",@"awayRedCard",@"homeYellowCard",@"awayYellowCard",@"yapan"];
    
#pragma mark  scoreView的设置
    self.BaseView = [[CommonTitleView alloc] init];

    self.view = _BaseView;
    
    self.BaseView.baseScrollView.delegate = self;
    
    
    // 左边
    self.BaseView.leftTableView.delegate = self;
    self.BaseView.leftTableView.dataSource = self;
    // 中间
    self.BaseView.centerTableView.delegate = self;
    self.BaseView.centerTableView.dataSource = self;
    // 右边
    self.BaseView.rightTableView.delegate = self;
    self.BaseView.rightTableView.dataSource = self;
    
    
    
    //添加筛选按钮
#pragma mark 添加筛选
    self.filterButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self.filterButton setTitle:@"筛选" forState:UIControlStateNormal];
    self.filterButton.frame = CGRectMake(kScreenWidth - kScreenIp6(70) ,kScreenIp6(25), kScreenIp6(50),kScreenIp6(30));
    [self.filterButton setTintColor:[UIColor whiteColor]];
    [self.filterButton addTarget:self action:@selector(filterAction:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:_filterButton];
    
    
    //标题
    [self.BaseView.recommendBtn setTitle:@"即时" forState:UIControlStateNormal];
    [self.BaseView.collectionBtn setTitle:@"赛果" forState:UIControlStateNormal];
    [self.BaseView.videoBtn setTitle:@"关注" forState:UIControlStateNormal];
    
 
    
    
    
    
    
    
    [self jiexiForScrole];
//    
    [self  jieXiScoreResult];
//    
    
    [self.BaseView.leftButton addTarget:self action:@selector(leftButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.BaseView.rightButton addTarget:self action:@selector(rightButton:) forControlEvents:UIControlEventTouchUpInside];
    [self.BaseView.nextButton addTarget:self action:@selector(nextButton:) forControlEvents:UIControlEventTouchUpInside];
    
    
    [self.BaseView.recommendBtn addTarget:self action:@selector(recommendBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.BaseView.collectionBtn addTarget:self action:@selector(collectionBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self.BaseView.videoBtn addTarget:self action:@selector(videoBtnAction) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.selected = NO;
    
    
    //下拉刷新
    [self TimePullDownToRefresh];
    
    
    [self  ScoreResultpullDownToRefresh];
    
    // 添加空白的 footView , 防止界面显示不全
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenIp6(5))];
    self.BaseView.rightTableView.tableFooterView = footerView;
    self.BaseView.centerTableView.tableFooterView = footerView;
    self.BaseView.leftTableView.tableFooterView = footerView;
    
    self.BaseView.leftTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.BaseView.centerTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.BaseView.rightTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

}



//添加定时器
-(void)addTimes
{
    //定时器
    self.scoreTimer = [NSTimer scheduledTimerWithTimeInterval:20 target:self selector:@selector(LiveChange:) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:self.scoreTimer forMode:NSRunLoopCommonModes];
    
    //冒号
    self.miaoTimer =  [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(maoHaoChange:) userInfo:nil repeats:YES];
    
    [[NSRunLoop currentRunLoop] addTimer:self.miaoTimer forMode:NSRunLoopCommonModes];
    
    
    
}







//移除定时器
-(void)removeTime
{
    
    [self.scoreTimer  invalidate];
    self.scoreTimer  = nil;

    
    [self.miaoTimer invalidate];
    self.miaoTimer = nil;
    
    
}







#pragma mark 定时刷新数据

-(void)LiveChange:(NSTimer*)sender
{
    //刷新小数据
    NSString *urlString = [NSString stringWithFormat:@"http://txt.win007.com/phone/livechange.txt?ran=%@",[self getMiaoShu] ];
    
//    NSLog(@"-----urlString-----%@",urlString);
    
    NSURL *url = [NSURL URLWithString:urlString];
    
    //异步解析
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0];
    
    
    [urlRequest addValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
    
    [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
     {
         if(data ==nil || response ==nil )
         {
             return ;
         }
         
         
         self.LiveChangeData = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
         
         
         [self devisionDataForLiveChange];
     }];
    
}

#pragma mark  定时器数据改变方法
-(void)devisionDataForLiveChange
{
    [self.BaseView.leftTableView reloadData];
    
    if(self.LiveChangeData.length != 0)
    {
        NSArray *liveArray = [self.LiveChangeData  componentsSeparatedByString:@"!"];
        
        
        if(liveArray.count != 0)
        {
            for(NSString *every in  liveArray)
            {
                NSMutableArray *everyArray = [[every componentsSeparatedByString:@"^"]mutableCopy];
                
                NSDictionary *everyDict = [NSDictionary dictionaryWithObjects:everyArray forKeys:_liveChangeKeysNameArray];
                
                
                ScoreModel *LiveModel =[ScoreModel ScoreModelWithDict:everyDict];
                
                NSLog(@"-------=====有事件发生================--=");
                
                
                
                for(int i = 0; i <   self.scoreModelArray.count; i++)
                {
                    
                    if([LiveModel.matchId isEqualToString:[self.scoreModelArray[i] matchId] ] )
                    {
                        
                        NSLog(@"-------=====刷新表格================--=");
                        
                        
                        NSIndexPath *indexpath = [NSIndexPath indexPathForRow:i inSection:0];
                        
                        LiveModel.leagueName = [self.scoreModelArray[i]leagueName];
                        
                        // 去掉 "(中)" 标识
                        LiveModel.homeName = [[[self.scoreModelArray[i] homeName] componentsSeparatedByString:@"("] firstObject];
                        LiveModel.awayName = [[[self.scoreModelArray[i] awayName]  componentsSeparatedByString:@"("] firstObject];
                        
                        self.scoreModelArray[i] = LiveModel;
                        
                        
                        //如果比赛完毕,从新解析
                        if ([LiveModel.matchState isEqualToString:@"3"])
                        {
                            [self jiexiForScrole];
                        }
                        //发送通知给第二个页面
                        [[NSNotificationCenter defaultCenter]postNotificationName:@"LiveChange" object:nil];
                        
                        
                        
                        [self.BaseView.leftTableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:  UITableViewRowAnimationFade];
                        
                    }
                 }
                
                
#warning 关注页面的数据同步更新
                for(int i = 0; i <   self.pointModelArray.count; i++)
                {
                    
                    if([LiveModel.matchId isEqualToString:[self.pointModelArray[i] matchId] ] )
                    {
                        
                        NSLog(@"-------=====刷新表格================--=");
                        
                        
                        NSIndexPath *indexpath = [NSIndexPath indexPathForRow:i inSection:0];
                        
                        LiveModel.leagueName = [self.scoreModelArray[i]leagueName];
                        
                        LiveModel.homeName = [[[self.scoreModelArray[i] homeName]  componentsSeparatedByString:@"("] firstObject];
                        LiveModel.awayName = [[[self.scoreModelArray[i] awayName] componentsSeparatedByString:@"("] firstObject];
                        
                        self.pointModelArray[i] = LiveModel;
                        
                        
                        //如果比赛完毕,从新解析
                        if ([LiveModel.matchState isEqualToString:@"3"])
                        {
                            [self jiexiForScrole];
                        }
                        
                        [self.BaseView.rightTableView reloadRowsAtIndexPaths:@[indexpath] withRowAnimation:  UITableViewRowAnimationFade];
                        
                    }
           
                    
                }
       
            }
            
        }
      
    }
}


#pragma mark  冒号会闪
-(void)maoHaoChange:(NSTimer*)sender
{
    
    self.isGreen= !self.isGreen;
    
    for(int i = 0; i < self.scoreModelArray.count; i++)
    {
        //1.首先找到正在比赛的
        ScoreModel *model = self.scoreModelArray[i];
        if([model.matchState isEqualToString:@"1"] || [model.matchState isEqualToString:@"3"])
        {
            
            
            NSIndexPath *modelPath = [NSIndexPath indexPathForRow:i inSection:0];
            
            //2.然后找到对应的cell
            ScoreTableViewCell *cell =( ScoreTableViewCell*)[self.BaseView.leftTableView  cellForRowAtIndexPath:modelPath];
            
            
            
            
            
            //3.改变cell的冒号
            
            if(self.isGreen)
            {
                
                cell.maohao.image = [UIImage imageNamed:@"colon_green@2x"];
            }
            else
            {
                cell.maohao.image = [UIImage imageNamed:@""];
                
            }
            
            
            
            
            
            
        }
    }
    
#warning 关注页面的同步刷新
    for(int i = 0; i < self.pointModelArray.count; i++)
    {
        //1.首先找到正在比赛的
        ScoreModel *model = self.pointModelArray[i];
        if([model.matchState isEqualToString:@"1"] || [model.matchState isEqualToString:@"3"])
        {
            
            
            NSIndexPath *modelPath = [NSIndexPath indexPathForRow:i inSection:0];
            
            //2.然后找到对应的cell
            ScoreTableViewCell *cell =( ScoreTableViewCell*)[self.BaseView.rightTableView  cellForRowAtIndexPath:modelPath];
            
            
            
            
            
            //3.改变cell的冒号
            
            if(self.isGreen)
            {
                
                cell.maohao.image = [UIImage imageNamed:@"colon_green@2x"];
            }
            else
            {
                cell.maohao.image = [UIImage imageNamed:@""];
                
            }
            
            
            
            
            
            
        }
    }

    
    
    
    
    
}





-(NSMutableArray *)pointModelArray
{
    if (_pointModelArray==nil)
    {
        self.pointModelArray = [NSMutableArray array];
    }
    
    return _pointModelArray;
    
}
#pragma mark - 下拉刷新


//刷新赛果
- (void)TimePullDownToRefresh
{
    __unsafe_unretained typeof(self) vc = self;
    [self.BaseView.leftTableView  addLegendHeaderWithRefreshingBlock:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            // 刷新表格
            [vc  jiexiForScrole];
            // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
            [vc.BaseView.leftTableView.header endRefreshing];
            [vc.BaseView.leftTableView  reloadData];
        });
    }];
}

//刷新赛果
- (void)ScoreResultpullDownToRefresh
{
    __unsafe_unretained typeof(self) vc = self;
    [self.BaseView.centerTableView  addLegendHeaderWithRefreshingBlock:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            // 刷新表格
            [vc  jieXiScoreResult];
            // (最好在刷新表格后调用)调用endRefreshing可以结束刷新状态
            [vc.BaseView.centerTableView.header endRefreshing];
            [vc.BaseView.centerTableView  reloadData];
        });
    }];
}




#pragma mark  解析比分

-(void)jiexiForScrole
{
    
    
    NSLog(@"-----下面是解析----------------------------------------");
    
    //
    //    NSString *urlString = [NSString stringWithFormat:@"http://txt.win007.com/phone/schedule_0_1.txt?ran=%@", [self getMiaoShu] ];
    
    
    
    NSString *urlString = [NSString stringWithFormat:@"http://txt.win007.com/phone/schedule_0_0.txt?ran=%@", [self getMiaoShu] ];
    
    NSURL *url = [NSURL URLWithString:urlString];
    
    //异步解析
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:5.0];
    
    
    [urlRequest addValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
    
    [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
     {
         if(data ==nil || response ==nil )
         {
             return ;
         }
         
         
         
         self.missCount = 0;
         
         self.scoreData = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
         
         [self  divisionDataForLeagueName];
         
         [self  divisionDataForMessage];
         
         //删选方法
         // [self  filterTeamLeagueActionForTime];
         
         self.arrayCount = self.arrayCount - self.missCount;
         
         [self.BaseView.leftTableView reloadData];
     }];
    
    
}


//分离数据
-(void)divisionDataForLeagueName
{
    
    
    //比赛ID
    self.leagueIDArray = [NSMutableArray array];
    
    //名字
    self.leagueNameArray = [NSMutableArray array];
#pragma mark  赛事筛选
    NSArray *first = [self.scoreData componentsSeparatedByString:@"$$"];
    
    NSArray *fenzu = [first[0] componentsSeparatedByString:@"!"];
    for (NSString *group in fenzu)
    {
        NSArray *everyGroup = [group componentsSeparatedByString:@"^"];
        
        
        //删选前的球赛名字
        [self.leagueNameArray addObject:[everyGroup firstObject] ];
        
        
        
        [self.leagueIDArray addObject:[everyGroup objectAtIndex:1]];
    }
    
    self.LeagueMessageDict = [NSDictionary dictionaryWithObjects:self.leagueIDArray forKeys: self.leagueNameArray];
    
    
    
}

-(void)divisionDataForMessage
{
    //比分model
    self.scoreModelArray = [NSMutableArray array];
    NSArray *first = [self.scoreData componentsSeparatedByString:@"$$"];
    
    
#pragma mark 比赛的信息
    NSArray *matchMessage = [first[1] componentsSeparatedByString:@"!"];
    
    self.arrayCount = matchMessage.count;
    
    
    for( NSString * every in matchMessage)
    {
        
        NSString*everyMatch = [every stringByReplacingOccurrencesOfString:@"^^^" withString:@"^"];
        
        
        
        
        NSMutableArray * everyArray = [[everyMatch componentsSeparatedByString:@"^"]mutableCopy];
        
        
        //正在比赛的
        if(everyArray.count ==20)
        {
            
            
            NSDictionary*everyDict = [NSDictionary dictionaryWithObjects:everyArray forKeys:self.goingKeysNameArray];
            
            
            ScoreModel *model =[ScoreModel ScoreModelWithDict:everyDict];
            
            
            
            
            if(self.filterTeamIDArray.count != 0)
            {
                for (int i = 0; i < self.filterTeamIDArray.count; i ++)
                {
                    
                    
                    if( [model.leagueId isEqualToString:self.filterTeamIDArray[i] ] )
                    {
                        
                        model.leagueName = self.filterTeamTitleArray[i];
                        
                        [self.scoreModelArray addObject:model];
                        
                        break;
                        
                    }
                }
                
            }
            
            else
            {
                for( int i = 0; i< self.leagueIDArray.count; i++)
                {
                    
                    if( [model.leagueId isEqualToString:self.leagueIDArray[i] ] )
                    {
                        
                        model.leagueName = self.leagueNameArray[i];
                        
                        [self.scoreModelArray addObject:model];
                        
                        break;
                    }
                    
                }
            }
            
        }
        //还未比赛的
        else if(everyArray.count ==18)
        {
            
            
            NSDictionary *everyDict = [NSDictionary dictionaryWithObjects:everyArray forKeys:self.fauterKeysNameArray];
            
            ScoreModel *model =[ScoreModel ScoreModelWithDict:everyDict];
            
            
            
            if(self.filterTeamIDArray.count != 0)
            {
                
                
                
                for (int i = 0; i < self.filterTeamIDArray.count; i ++)
                {
                    
                    
                    if( [model.leagueId isEqualToString:self.filterTeamIDArray[i] ] )
                    {
                        
                        model.leagueName = self.filterTeamTitleArray[i];
                        [self.scoreModelArray   addObject:model];
                        
                        break;
                        
                    }
                }
                
                
                
            }
            else
            {
                for( int i = 0; i< self.leagueIDArray.count; i++)
                {
                    
                    if( [model.leagueId isEqualToString:self.leagueIDArray[i] ] )
                    {
                        
                        model.leagueName = self.leagueNameArray[i];
                        [self.scoreModelArray   addObject:model];
                        
                        break;
                    }
                    
                }
                
                
                
            }
        }
        else
        {
            
            // 1147537^1181^-1^20150713150000^20150713160200^巴西大学(中)^日本大学^0^0^0^0^0^0^1^0^-0.25^^^0^2^1^90,0-0;;;6-7;1^^2
            self.missCount = self.missCount + 1;
            
        }
        
        
    }
    
    
}







#pragma mark  解析赛果
//参数date
-(NSString*)getTime
{
    //获取时间
    NSDate *date = [NSDate   dateWithTimeIntervalSinceNow:-24*3600   ];

    NSDateFormatter *dateFormate = [[NSDateFormatter  alloc]init];
    [dateFormate setDateFormat:@"YYYY-MM-dd"];
    
    NSString *curentDate = [dateFormate  stringFromDate:date];
    
    //NSLog(@"curentDate--%@",curentDate);
    return curentDate;
}

//现在的秒数

-(NSString *)getMiaoShu
{
    
    NSDate *today = [NSDate date];
    
    
    double dureen = [today timeIntervalSince1970];
    
    NSString *timeString = [NSString stringWithFormat:@"%f",dureen];
    
    
    NSString* miao = [[timeString componentsSeparatedByString:@"."]objectAtIndex:0];
    NSString *haomiao = [[timeString componentsSeparatedByString:@"."]objectAtIndex:1];
    
    
    
    NSString *subHaomiao =[haomiao substringToIndex:3];
    
    NSString * totalTime = [NSString stringWithFormat:@"%@%@",miao,subHaomiao];
    return totalTime;
    
}


#pragma mark  解析赛果--jieXiScoreResult

-(void)jieXiScoreResult
{
    NSString *urlString = [NSString stringWithFormat:@"http://apk.win007.com/phone/scheduleByDate.aspx?lang=0&date=%@&ran=%@", [self getTime],[self getMiaoShu ] ];
    
    NSURL *url = [NSURL URLWithString:urlString];
    
    //异步解析
    NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
    
    
    [urlRequest addValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"];
    
    [NSURLConnection sendAsynchronousRequest:urlRequest queue:[NSOperationQueue mainQueue]completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError)
     {
         if(data ==nil || response ==nil )
         {
             return ;
         }
         
         
         self.resultScoreData = [[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];
         
         
         [self  divisionResultLeagueTeam];
         [self  divisionResultMessage];
         
         // [self   filterTeamLeagueActionForResult];
         
         
         
         
         [self.BaseView.centerTableView reloadData];
     }];
    
}

-(void)divisionResultLeagueTeam
{
    self.leagueIDResultArray = [NSMutableArray array];
    self.leagueNameResultArray = [NSMutableArray array];
    
    
#pragma mark  赛事筛选
    NSArray *first = [self.resultScoreData componentsSeparatedByString:@"$$"];
    
    NSArray *fenzu = [first[1] componentsSeparatedByString:@"!"];
    for (NSString *group in fenzu)
    {
        NSArray *everyGroup = [group componentsSeparatedByString:@"^"];
        
        
        
        [self.leagueNameResultArray addObject:[everyGroup firstObject] ];
        
        
        [self.leagueIDResultArray addObject:[everyGroup objectAtIndex:1]];
    }
    self. resultLeagueMessageDict = [NSDictionary dictionaryWithObjects:self.leagueIDResultArray forKeys:self.leagueNameResultArray];
}
-(void)divisionResultMessage
{
    
    
    
    //赛果model
    self.scoreResultModelArray = [NSMutableArray array];
    
#pragma mark 比赛的信息
    NSArray *first = [self.resultScoreData componentsSeparatedByString:@"$$"];
    
    NSArray *matchMessage = [first[2] componentsSeparatedByString:@"!"];
    
    self.scoreResultCount = matchMessage.count;
    
    
    for( NSString * everyRow in matchMessage)
    {
        
        NSMutableArray * everyArray = [[everyRow componentsSeparatedByString:@"^"]mutableCopy];
#warning  先不显示  各自的排名
        //删除从15之后的数据,包括15
        [everyArray removeObjectsInRange:NSMakeRange(15, everyArray.count-15) ];
        
        
        NSDictionary*everyDict = [NSDictionary dictionaryWithObjects:everyArray forKeys:self.scoreResultKeysNameArray];
        
        ScoreModel *model =[ScoreModel ScoreModelWithDict:everyDict];
        
        if(self.ResultFilterTeamIDArray.count != 0)
        {
            
            for (int i = 0; i < self.ResultFilterTeamIDArray.count; i ++)
            {
                
                
                if( [model.leagueId isEqualToString:self.ResultFilterTeamIDArray[i] ] )
                {
                    
                    model.leagueName = self.ResultFilterTeamTitleArray[i];
                    
                    [self.scoreResultModelArray addObject:model];
                    
                    break;
                    
                }
            }
            
        }
        else
        {
            for (int i = 0; i < self.leagueIDResultArray.count; i ++)
            {
                
                
                if( [model.leagueId isEqualToString:self.leagueIDResultArray[i] ] )
                {
                    
                    model.leagueName = self.leagueNameResultArray[i];
                    
                    [self.scoreResultModelArray addObject:model];
                    
                    break;
                    
                }
            }
            
            
        }
        
    }
    
}


#pragma mark - 代理方法


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if(tableView ==self.BaseView.leftTableView)
    {
        
        return  self.scoreModelArray.count;
        
        
    }
    else if(tableView ==self.BaseView.centerTableView)
    {
        
        return self.scoreResultModelArray.count;
    }
    else
    {
        return self.pointModelArray.count;
        
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if(tableView ==self.BaseView.leftTableView)
    {
        static NSString *cellIndetifier = @"ScoreCell";
        [tableView registerClass:[ScoreTableViewCell class] forCellReuseIdentifier:cellIndetifier];
        
        ScoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndetifier forIndexPath:indexPath];
        
        ScoreModel*model = self.scoreModelArray[indexPath.row];
        model.isSelectPoint =NO;
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        [cell.attentionIcon  addTarget:self action:@selector(pointAcion:) forControlEvents:UIControlEventTouchUpInside];
        
        
        
        
        for(ScoreModel *modelPoint  in self.pointModelArray)
            
        {
            
            
            
            
            if([model.matchId isEqualToString:modelPoint.matchId])
            {
                model.isSelectPoint =YES;
                
                
            }
            
            
        }
        
        
        
        if(model.isSelectPoint)
        {
            
            [cell.attentionIcon  setBackgroundImage:[UIImage imageNamed:@"football_collected_small_1@2x"] forState:UIControlStateNormal];
            
        }
        else
        {
            
            
            [cell.attentionIcon setBackgroundImage:[UIImage imageNamed:@"football_collect_small_1"] forState:UIControlStateNormal];
            
            
        }
        
        
        
        
        
        
        
        [cell setCellValue:model];
        
        
        return cell;
        
    }
    else if(tableView ==self.BaseView.centerTableView)
    {
        
        static NSString *cellIndetifier = @"ScoreResultCell";
        [tableView registerClass:[ScoreResultTableViewCell class] forCellReuseIdentifier:cellIndetifier];
        
        ScoreResultTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndetifier forIndexPath:indexPath];
        
        ScoreModel *model = self.scoreResultModelArray[indexPath.row];
        
        [cell setCellValue:model];
        
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
        
    }
    else
    {
        
        static NSString *cellIndetifier = @"pointCell";
        [tableView registerClass:[ScoreTableViewCell class] forCellReuseIdentifier:cellIndetifier];
        
        ScoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIndetifier forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        
        ScoreModel*model = self.pointModelArray[indexPath.row];
        
        
        if(model.isSelectPoint)
        {
            
            [cell.attentionIcon  setBackgroundImage:[UIImage imageNamed:@"football_collected_small_1@2x"] forState:UIControlStateNormal];
            
        }
        
        
        
        [cell setCellValue:model];
        
        [cell.attentionIcon addTarget:self action:@selector(alarmAction:) forControlEvents:UIControlEventTouchUpInside];
        
        
        
        
        
        return cell;
        
        
        
    }
    
    
    
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kScreenIp6(75);
}



#pragma mark  点击cell
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // 点击 cell 之前先判断 rightButton 是否是隐藏的
    if (self.BaseView.rightButton.hidden) {
        
        if(tableView ==self.BaseView.leftTableView)
        {
            
            ScoreModel *model = self.scoreModelArray[indexPath.row];
            
            EventAndAnalysisViewController *eventAndAnalysisVC= [[EventAndAnalysisViewController alloc]init];
            
            eventAndAnalysisVC.matchID = model.matchId;
            eventAndAnalysisVC.leagueName = model.leagueName;
            
           
            
            
            [self.navigationController pushViewController:eventAndAnalysisVC animated:YES];
            
            
        }
        
        else if(tableView  == self.BaseView.centerTableView)
        {
            
            
            ScoreModel *model = self.scoreResultModelArray[indexPath.row];
            
            EventAndAnalysisViewController *eventAndAnalysisVC= [[EventAndAnalysisViewController alloc]init];
            
            eventAndAnalysisVC.matchID = model.matchId;
            eventAndAnalysisVC.leagueName = model.leagueName;
            
            [self.navigationController pushViewController:eventAndAnalysisVC animated:YES];
            
            
        }
        else
        {
            ScoreModel *model = self.pointModelArray[indexPath.row];
            
            EventAndAnalysisViewController *eventAndAnalysisVC= [[EventAndAnalysisViewController alloc]init];
            
            eventAndAnalysisVC.matchID = model.matchId;
            eventAndAnalysisVC.leagueName = model.leagueName;
            
            [self.navigationController pushViewController:eventAndAnalysisVC animated:YES];
            
            
            
            
        }
        
    }
    
    else
    {
        [self leftButton:self.BaseView.leftButton];
    }
    
}



#pragma mark button点击方法


#pragma mark - 点击导航栏右边按钮
- (void)rightButton:(UIButton *)sender
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    
    self.BaseView.rightButton.hidden = YES;
    self.BaseView.nextButton.hidden = NO;
    NSString *string = self.BaseView.leftButton.titleLabel.text;
    [self.BaseView.leftButton setTitle:self.BaseView.rightButton.titleLabel.text forState:UIControlStateNormal];
    [self.BaseView.rightButton setTitle:string forState:UIControlStateNormal];
    self.BaseView.leftButton.frame = CGRectMake((kScreenWidth - kBtnWidth- kScreenIp6(10)) / 2, kTitleY, kBtnWidth, kBtnHeight);
    
    [UIView commitAnimations];
    self.selected = !self.selected;
    [self.BaseView.leftTableView reloadData];
    [self.BaseView.centerTableView reloadData];
    //    NSLog(@"%d",self.selected);
    
#pragma mark  跳转到篮球
    
    FootballViewController *bassketbaallVC= [[FootballViewController alloc]init];
    
    [self.navigationController pushViewController:bassketbaallVC animated:NO];
    
    
}

- (void)leftButton:(UIButton *)sender
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationDelegate:self];
    
    if (self.BaseView.rightButton.hidden)
    {
        self.BaseView.rightButton.hidden = NO;
        self.BaseView.nextButton.hidden = YES;
        self.BaseView.leftButton.frame = CGRectMake(kScreenWidth / 2 - kBtnWidth - kScreenIp6(10), kTitleY, kBtnWidth, kBtnHeight);
    }
    else
    {
        self.BaseView.rightButton.hidden = YES;
        self.BaseView.nextButton.hidden = NO;
        self.BaseView.leftButton.frame = CGRectMake((kScreenWidth - kBtnWidth- kScreenIp6(10)) / 2, kTitleY, kBtnWidth, kBtnHeight);
    }
    [UIView commitAnimations];
    
}

- (void)nextButton:(UIButton *)sender
{
    [self leftButton:self.BaseView.leftButton];
}

#pragma mark - 点击屏幕默认选择左边按钮
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (!self.BaseView.rightButton.hidden)
    {
        [self leftButton:self.BaseView.leftButton];
    }
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    
}



- (void)recommendBtnAction
{
    if (self.BaseView.rightButton.hidden) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        
        
        self.BaseView.baseScrollView.contentOffset = CGPointMake(0, 0);
        [self switchButtonPoint];
        
        
        [UIView commitAnimations];
    }
    else
    {
        [self leftButton:self.BaseView.leftButton];
    }
}

- (void)collectionBtnAction
{
    if (self.BaseView.rightButton.hidden) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        
        
        self.BaseView.baseScrollView.contentOffset = CGPointMake(kScreenWidth, 0);
        [self switchButtonPoint];
        
        
        [UIView commitAnimations];
    }
    else
    {
        [self leftButton:self.BaseView.leftButton];
    }
}


- (void)videoBtnAction
{
    if (self.BaseView.rightButton.hidden) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationDelegate:self];
        
        
        self.BaseView.baseScrollView.contentOffset = CGPointMake(kScreenWidth*2, 0);
        [self switchButtonPoint];
        
        
        [UIView commitAnimations];
        
        
        [self NowHasNoPoint];
    }
    else
    {
        [self leftButton:self.BaseView.leftButton];
    }
}


#pragma mark - 拖动中执行
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];
    
    int i = (self.BaseView.baseScrollView.contentOffset.x + kScreenWidth/2) / kScreenWidth;
    self.BaseView.pointImage.center = CGPointMake((i * kScreenWidth/3 + kScreenWidth/6), kScreenIp6(106));
    
    [UIView commitAnimations];
}

#pragma mark 拖拽后减速停止触发
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationDelegate:self];
    
    [self switchButtonPoint];
    
    [UIView commitAnimations];
    
    
    if (scrollView.contentOffset.x == kScreenWidth *2)
    {
        
        [self NowHasNoPoint];
        
    }

    
}

// 切换 Button 指向
- (void)switchButtonPoint
{
    if (self.BaseView.baseScrollView.contentOffset.x == 0)
    {
        self.BaseView.pointImage.center = CGPointMake(kScreenWidth/6, kScreenIp6(106));
        [self.BaseView.recommendBtn setTintColor:[UIColor whiteColor]];
        [self.BaseView.collectionBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.BaseView.videoBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
#pragma mark 处理筛选按钮的状态
        self.filterButton.enabled = YES;
    }
    else if (self.BaseView.baseScrollView.contentOffset.x == kScreenWidth)
    {
        self.BaseView.pointImage.center = CGPointMake(kScreenWidth/2, kScreenIp6(106));
        [self.BaseView.collectionBtn setTintColor:[UIColor whiteColor]];
        [self.BaseView.recommendBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.BaseView.videoBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        self.filterButton.enabled = YES;
    }
    else
    {
        self.BaseView.pointImage.center = CGPointMake(kScreenWidth*5/6, kScreenIp6(106));
        [self.BaseView.videoBtn setTintColor:[UIColor whiteColor]];
        [self.BaseView.collectionBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        [self.BaseView.recommendBtn setTintColor:[UIColor colorWithWhite:0.900 alpha:1.000]];
        self.filterButton.enabled = NO;
    }
}



#pragma mark   筛选按钮
-(void)filterAction:(UIButton*)sender
{
    FilterTeamViewController *filterVC= [[FilterTeamViewController alloc]init];
    //即时
    if (self.BaseView.baseScrollView.contentOffset.x == 0)
    {
        
        filterVC.timeTransferModelArray = self .leagueNameArray;
        
        filterVC.filterFirstModelArray = [self.filterTeamTitleArray mutableCopy];
        
        [self.navigationController pushViewController:filterVC animated:YES];
        
        
        __weak  ScoreViewController *BlockSelf = self;
        
        filterVC.block = ^(NSMutableArray *array){
            
            BlockSelf.filterTeamIDArray = [NSMutableArray array];
            
            BlockSelf.filterTeamTitleArray = array;
            
            [self filterTeamLeagueActionForTime];
            
        };
        
        
        
    }
    //赛果
    else  if(self.BaseView.baseScrollView.contentOffset.x ==kScreenWidth )
    {
        
        filterVC.resultTransferModelArray = self.leagueNameResultArray;
        
        filterVC.filterFirstModelArray = [self.ResultFilterTeamTitleArray mutableCopy];
        
        
        [self.navigationController pushViewController:filterVC animated:YES];
        
        
        
        __block  ScoreViewController *BlockSelf = self;
        
        
        filterVC.block = ^(NSMutableArray *array)
        {
            BlockSelf.ResultFilterTeamTitleArray = [NSMutableArray array];
            BlockSelf.ResultFilterTeamTitleArray = array;
            
            [self filterTeamLeagueActionForResult];
            
        };
        
    }
    
    
}



-(NSMutableArray*)filterTeamIDArray
{
    if (_filterTeamIDArray==nil)
    {
        self.filterTeamIDArray = [NSMutableArray array];
    }
    return _filterTeamIDArray;
}



#pragma mark  删选球赛方法---即时
-(void)filterTeamLeagueActionForTime
{
    

    
    UIView *noDataView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    noDataView.backgroundColor = [UIColor whiteColor];
 
    UIImageView *pointPicture = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth/2 - kScreenIp6(100), kScreenIp6(100), kScreenIp6(200), kScreenIp6(200))];
    pointPicture.image = [UIImage imageNamed:@"Empty_Hint_ZZZ@2x"];
    
    [noDataView addSubview:pointPicture];
    
    
    //删选出来的球赛
    //self.filterTeamTitleArray = [[NSUserDefaults standardUserDefaults]objectForKey:@"filterTime"];
    
    
    
    
    if(self.filterTeamTitleArray.count != 0  && self.leagueNameArray.count != 0  )
    {
        
        
        [noDataView removeFromSuperview];
        [self.BaseView.baseScrollView addSubview:self.BaseView.leftTableView];
        
        
        for (int i = 0; i < self.filterTeamTitleArray.count; i++)
        {
            
            
            
            NSString *teamID = [self.LeagueMessageDict  objectForKey:self.filterTeamTitleArray[i]];
            if (teamID !=nil  && teamID.length !=0  && ![self.filterTeamIDArray containsObject:teamID])
            {
                [self.filterTeamIDArray addObject: teamID];
            }
            
        }
        
        [self divisionDataForMessage];
        [self.BaseView.leftTableView  reloadData];
        
    }
    else
    {
        //        //没有数据
        
        [self.BaseView.baseScrollView  addSubview:noDataView];
        
    }
    
}




#pragma mark  删选赛果
-(void)filterTeamLeagueActionForResult
{
    
    
    UIView *noDataView = [[UIView alloc]initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, kScreenHeight)];
    noDataView.backgroundColor = [UIColor whiteColor];
    
    
    
    UIImageView *pointPicture = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth/2 - kScreenIp6(100), kScreenIp6(100), kScreenIp6(200), kScreenIp6(200))];
    pointPicture.image = [UIImage imageNamed:@"Empty_Hint_ZZZ@2x"];
    
    [noDataView addSubview:pointPicture];
    
    
    
    
    
    self.ResultFilterTeamIDArray = [NSMutableArray array];
    
    
    //删选出来的球赛
    // self.ResultFilterTeamTitleArray = [[NSUserDefaults standardUserDefaults]objectForKey:@"filterResult"];
    
    
    if(self.ResultFilterTeamTitleArray.count != 0  && self.leagueNameResultArray.count != 0  )
    {
        
        
        [noDataView removeFromSuperview];
        [self.BaseView.baseScrollView addSubview:self.BaseView.centerTableView];
        
        
        for (int i = 0; i < self.ResultFilterTeamTitleArray.count; i++)
        {
          
            NSString *teamID = [self.resultLeagueMessageDict  objectForKey:self.ResultFilterTeamTitleArray[i]];
            if (teamID !=nil  && teamID.length !=0  && ![self.ResultFilterTeamIDArray containsObject:teamID])
            {
                [self.ResultFilterTeamIDArray addObject: teamID];
            }
            
        }
        
        [self divisionResultMessage];
        [self.BaseView.centerTableView  reloadData];
        
    }
    else
    {
        
        [self.BaseView.baseScrollView  addSubview:noDataView];
        
        
    }
    
    
    
}



#pragma mark  关注按钮
-(void)pointAcion:(UIButton*)sender
{
    
    
    ScoreTableViewCell *cell = (ScoreTableViewCell*)[[sender superview]superview];
    
    NSIndexPath * path = [self.BaseView.leftTableView indexPathForCell:cell];
    
    ScoreModel *modelPoint = self.scoreModelArray[path.row];
    
    
    
    modelPoint.isSelectPoint = !modelPoint.isSelectPoint;
    
    if (  modelPoint.isSelectPoint   )
    {
        
        [cell.attentionIcon  setBackgroundImage:[UIImage imageNamed:@"football_collected_small_1@2x"] forState:UIControlStateNormal];
        
        
        [self.pointModelArray addObject:modelPoint];
        
        
        //添加到数据库
        [[MyFootballPointTool sharedMyFootballPointTool]creatTable];
        [[MyFootballPointTool sharedMyFootballPointTool]addDataWithModel:modelPoint];
        
        
        
        
        [self.BaseView.leftTableView reloadData];
        [self.BaseView.rightTableView reloadData];
        
        
    }
    else
    {
        
        
        
        
        [cell.attentionIcon  setBackgroundImage:[UIImage imageNamed:@"football_collect_small_1"] forState:UIControlStateNormal];
        
        
        
        
        for(int i= 0; i< self.pointModelArray.count;i++)
        {
            if([ [self.pointModelArray[i] matchId] isEqualToString:modelPoint.matchId])
                
            {
                
                [self.pointModelArray removeObjectAtIndex:i];
                
                
            }
            
            
        }
        
        //删除
        [[MyFootballPointTool sharedMyFootballPointTool]creatTable];
        [[MyFootballPointTool sharedMyFootballPointTool]deleteModel:modelPoint];
        
        [self.BaseView.leftTableView reloadData];
        [self.BaseView.rightTableView reloadData];
    }
    
    
    //暂无关注
    [self NowHasNoPoint];
    
  
}
#pragma mark  关注中取消
-(void)alarmAction:(UIButton*)sender
{
    
    
    
    ScoreTableViewCell *cell = (ScoreTableViewCell*)[[sender superview] superview];
    
    NSIndexPath * path = [self.BaseView.rightTableView indexPathForCell:cell];
    
    ScoreModel *model = self.pointModelArray[path.row];
    
    model.isSelectPoint = !model.isSelectPoint;
    
    
    
    if(!model.isSelectPoint)
    {
        
        
        [self.pointModelArray removeObject:model];
        
        
        
        
        //删除关注
        //删除
        [[MyFootballPointTool sharedMyFootballPointTool]creatTable];
        [[MyFootballPointTool sharedMyFootballPointTool]deleteModel:model];
        //
        
        [self.BaseView.leftTableView reloadData];
        [self.BaseView.rightTableView reloadData];
        
        
        
    }
    
    //暂无关注
    [self NowHasNoPoint];
    
    //
    //    sender.selected = !sender.selected;
    //
    //    if (sender.selected)
    //    {
    //        ScoreModel *model = self.pointModelArray[sender.tag - 200];
    //
    //        model.isSelectAlarm =YES;
    //
    //
    //
    //
    ////
    ////       NSMutableString *tempTime = [model.startTime mutableCopy];
    ////
    ////        [tempTime  insertString:@"-" atIndex:4];
    ////         [tempTime  insertString:@"-" atIndex:7];
    ////        [tempTime insertString:@" " atIndex:10];
    ////          [tempTime insertString:@":" atIndex:13];
    ////         [tempTime insertString:@":" atIndex:16];
    ////
    ////        NSDateFormatter *format = [[NSDateFormatter alloc]init];
    ////        [format setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    ////        NSDate *matchDate = [format dateFromString:tempTime ];
    ////
    //
    //
    //    NSString *alarmTitle = [NSString stringWithFormat: @"%@ VS %@",model.homeName,model.awayName];
    //
    //      NSDate *matchDate = [NSDate dateWithTimeIntervalSinceNow:60*2];
    //
    //
    //        [AlarmClockManager addAlarmClockWithFireDate:matchDate activityId:[model.matchId intValue] activityTitle:alarmTitle];
    //
    //
    //
    //
    //        [self.scoreView.rightTableView reloadData];
    //
    //
    //    }
    //    else
    //    {
    //
    //        ScoreModel *model = self.pointModelArray[sender.tag - 200];
    //
    //         model.isSelectAlarm =NO;
    //
    //        [AlarmClockManager  removeAlarmClockWithActivityId:[model.matchId  intValue] ];
    //
    //
    //
    //        [self.scoreView.rightTableView reloadData];
    //
    //
    //
    //    }
    //
    
}

#pragma mark  暂无关注
-(void)NowHasNoPoint
{
    
    
    //没有关注的时候
    
    
    UIView *noDataView = [[UIView alloc]initWithFrame:CGRectMake(kScreenWidth*2, 0, kScreenWidth, kScreenHeight)];
    noDataView.backgroundColor = [UIColor whiteColor];
    
    
    
    UIImageView *pointPicture = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth/2 - kScreenIp6(100), kScreenIp6(100), kScreenIp6(200), kScreenIp6(200))];
    pointPicture.image = [UIImage imageNamed:@"Empty_Hint_Fav@2x"];
    
    
    [noDataView addSubview:pointPicture];
    
//    NSLog(@"self.pointModelArray.count--%ld",self.pointModelArray.count);
    
    if(self.pointModelArray.count == 0)
    {
        
        [self.BaseView.baseScrollView  addSubview:noDataView];

    }
    else
    {
        
        [noDataView removeFromSuperview];
        [self.BaseView.baseScrollView addSubview:self.BaseView.rightTableView];
        
        
    }
    
    
    
    
    
}

#pragma mark - 隐藏和显示状态栏
- (void)viewWillAppear:(BOOL)animated
{
    
    self.navigationController.navigationBarHidden = YES;
    
    
    [self.BaseView.leftButton setTitle:@"足球" forState:UIControlStateNormal];
    [self.BaseView.rightButton setTitle:@"篮球" forState:UIControlStateNormal];
    
    //#warning 删除所有数据
    [self.pointModelArray removeAllObjects];
    [[MyFootballPointTool sharedMyFootballPointTool]creatTable];
    
    
    self.pointModelArray =[[[MyFootballPointTool sharedMyFootballPointTool]getModels]mutableCopy];
    //
    
    
    [self jiexiForScrole];
    //
    [self  jieXiScoreResult];
    //
    
    
}

- (void)viewWillDisappear:(BOOL)animated
{
    self.navigationController.navigationBarHidden = NO;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
